﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using LTP.Accounts.Bus;
using System.Web.Security;
namespace TCS.Web.Service
{
    /// <summary>
    /// Login 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Login : System.Web.Services.WebService
    {

        //[WebMethod]
        //public string HelloWorld(string s)
        //{
        //    return "Hello World "+ s;
        //}
        [WebMethod]
        public string VerifyUserNameAndPwd(string username, string pwd)
        {
            AccountsPrincipal newUser = AccountsPrincipal.ValidateLogin(username,pwd);

            if (newUser == null)
            {
                return "0";

            }
            else
            {
                User currentUser = new LTP.Accounts.Bus.User(newUser);
                Context.User = newUser;
                if (((SiteIdentity)User.Identity).TestPassword(pwd) == 0)
                {
                    return "0";
                }
                else
                {
                    return "1";
                }
            }
        }

    }
}
